package com.edu.exam.entity.examination.paper.technical;

import com.edu.exam.enums.examination.paper.ArchiveStatus;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 标准化图像实体类
 *
 * 根据E-04-02图像处理子模块数据库设计实现
 * 存储标准化处理后的图像信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class StandardizedImage {

    /**
     * 标准化图像ID，主键
     */
    @Id
    @Column(name = "image_id", length = 64)
    private String imageId;

    /**
     * 处理记录ID
     */
    @Column(name = "processing_record_id", length = 64, nullable = false)
    private String processingRecordId;

    /**
     * 标准化文件名
     */
    @Column(name = "standardized_filename", length = 255, nullable = false)
    private String standardizedFilename;

    /**
     * 标准化格式
     */
    @Column(name = "standardized_format", length = 10, nullable = false)
    private String standardizedFormat;

    /**
     * 标准化宽度
     */
    @Column(name = "standardized_width", nullable = false)
    private Integer standardizedWidth;

    /**
     * 标准化高度
     */
    @Column(name = "standardized_height", nullable = false)
    private Integer standardizedHeight;

    /**
     * 标准化DPI
     */
    @Column(name = "standardized_dpi", precision = 5, scale = 1, nullable = false)
    private Double standardizedDpi;

    /**
     * 文件大小（字节）
     */
    @Column(name = "file_size_bytes", nullable = false)
    private Long fileSizeBytes;

    /**
     * 存储路径
     */
    @Column(name = "storage_path", length = 500, nullable = false)
    private String storagePath;

    /**
     * 存储类型
     */
    @Column(name = "storage_type", length = 20, nullable = false)
    private String storageType;

    /**
     * 压缩质量
     */
    @Column(name = "compression_quality")
    private Integer compressionQuality;

    /**
     * 色彩空间
     */
    @Column(name = "color_space", length = 20, nullable = false)
    private String colorSpace;

    /**
     * 位深度
     */
    @Column(name = "bit_depth")
    private Integer bitDepth;

    /**
     * 是否有水印
     */
    @Column(name = "has_watermark")
    private Boolean hasWatermark;

    /**
     * 水印配置
     */
    @Column(name = "watermark_config", columnDefinition = "TEXT")
    private String watermarkConfig;

    /**
     * MD5校验和
     */
    @Column(name = "checksum_md5", length = 32, nullable = false)
    private String checksumMd5;

    /**
     * SHA256校验和
     */
    @Column(name = "checksum_sha256", length = 64, nullable = false)
    private String checksumSha256;

    /**
     * 备份路径
     */
    @Column(name = "backup_path", length = 500)
    private String backupPath;

    /**
     * 备份时间
     */
    @Column(name = "backup_time")
    private LocalDateTime backupTime;

    /**
     * 归档状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "archive_status", length = 20)
    private ArchiveStatus archiveStatus;

    // ===== 审计字段 =====

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version")
    private Integer version = 0;

    /**
     * 逻辑删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}